package com.da_ping;

import java.io.OutputStream;

import javax.servlet.http.HttpServletResponse;

public class BaseController {
	public void outJson(HttpServletResponse response, String json) {
		try {
			response.setContentType("application/json; charset=utf-8");
			response.setCharacterEncoding("UTF-8");
			OutputStream out = response.getOutputStream();
			out.write(json.getBytes("UTF-8"));
			out.flush();
			out.close();
			Util.outLog(json, new Exception());
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	public void success(HttpServletResponse response) {
		outJson(response, "{\"code\":1}");
	}
	public void fail(HttpServletResponse response) {
		outJson(response, "{\"code\":0}");
	}
}
